#ifndef _DBCACHE_HXX_
#define _DBCACHE_HXX_

#include "mytypes.h"
#include <map>
#include <string>
#include "mythread.hxx"
#include "mymutex.hxx"
using namespace std;

class GisusSWFileSet;
class DBCache
{
public:
  typedef map<pair<string,string>,string> tSoftwareIdCacheContainer;
  typedef map<pair<pair<string,string>,string>,GisusSWFileSet> tSWFileCacheContainer;
  typedef map<pair<tUInt32,tUInt16>, string> tChunkFileCacheContainer;

  DBCache();
  ~DBCache();
  bool GetSoftwareId(const string &model, const string &com_ref, string &softwareid) const;
  void SetSoftwareId(const string &model, const string &com_ref, const string &softwareid);

  bool GetSWFiles(const string &model, const string &comref, const string &softwareid, GisusSWFileSet *gisusswfileset) const;
  void SetSWFiles(const string &model, const string &comref, const string &softwareid, GisusSWFileSet *gisusswfileset);
 
  bool GetChunkFileName(tUInt32 fileid,tUInt16 chunkid, string &chunkfilename) const;
  void SetChunkFileName(tUInt32 fileid,tUInt16 chunkid, const string &chunkfilename);
 
private:
  tSoftwareIdCacheContainer _softwareid;
  mutable Mutex _softwareid_protect;
  
  tSWFileCacheContainer _swfiles;
  mutable Mutex _swfiles_protect;
  
  tChunkFileCacheContainer _chunkfile;
  mutable Mutex _chunkfile_protect;
};


#endif // _DBCACHE_HXX_
